package com.globallogic.javatrainings.sergiiivanov.controller;

import org.junit.Test;

import com.globallogic.javatrainings.sergiiivanov.model.University;
import com.globallogic.javatrainings.sergiiivanov.view.GUI;

@SuppressWarnings("unused")
public class ControllersTest {

    @Test
    public void testNewFromScratch() throws Exception {
        // Test disabled till test data completion
        /*
         * InputController.setInputFile("auto_scratch.txt"); University u = new
         * University("test from scratch"); Main.mainBody(u);
         */
    }

    /**
     * Covers controllers by simulating user input<br>
     * Mechanics: replaces System.in with text file
     * "test_data/auto_template.txt" for user input<br>
     * <b>WARNING! Output is not validated - only errors are subjects of this
     * run</b><br>
     * 
     * @throws Exception
     */
    @Test
    public void testNewFromTemplate() throws Exception {
        InputController.setInputFile("test_data/auto_template.txt");
        University u = UniversityTemplates.universityTemplte1();
        GUI.getGUI().mute(true);
        Main.mainStart(new String[] {});
        Main.mainBody(u);
    }

    public void save(University u) throws Exception {
        DataReader dr = new DataReader();
        dr.fileName = "Spec_rec_save_test.usav";
        dr.saveDataToFile(u);
    }

    public University load() throws Exception {
        DataReader dr = new DataReader();
        dr.fileName = "Spec_rec_save_test.usav";
        return dr.readData();
    }
}
